package com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.service.impl;

import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.vo.TowerDataAlarmSearchVO;
import com.jxdinfo.hussar.support.mp.base.service.impl.HussarServiceImpl;
import com.jxdinfo.hussar.support.datasource.annotations.HussarDs;
import com.jxdinfo.hussar.platform.core.utils.HussarUtils;
import com.jxdinfo.hussar.support.exception.HussarException;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.model.TowerDataAlarm;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.service.TowerDataAlarmService;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.dao.TowerDataAlarmMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;
import com.jxdinfo.hussar.cloud.module.example.tjjc.towerdataalarm.vo.TowerDataAlarmPageVO;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import java.util.Map;
import com.jxdinfo.hussar.support.mp.base.query.generator.SingleTableQueryGenerator;
import java.util.HashMap;
import com.jxdinfo.hussar.support.mp.base.query.generator.superquery.SuperQueryGenerator;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;

/**
 * 塔机报警数据服务实现类
 */
@Service("tjjc.towerdataalarm.TowerDataAlarmServiceImpl")
@HussarDs("master")
public class TowerDataAlarmServiceImpl extends HussarServiceImpl<TowerDataAlarmMapper, TowerDataAlarm> implements TowerDataAlarmService {

    private static final Logger logger = LoggerFactory.getLogger(TowerDataAlarmServiceImpl.class);

    private static final String RETURN_CODE = "0";

    @Autowired
    private TowerDataAlarmMapper towerDataAlarmMapper;

    @Override
    public ApiResponse<Map<String, Long>> findTowerTodayAlarmCount(TowerDataAlarmSearchVO towerDataAlarmSearchVO) {
        Map<String, Long> alarmMap = new HashMap<>();

        //获取报警数量
        QueryWrapper<TowerDataAlarm> wrapper = new QueryWrapper<>();
        wrapper.eq("tower_id", towerDataAlarmSearchVO.getTowerId());
        wrapper.eq("ty_project_code", towerDataAlarmSearchVO.getTyProjectCode());
        wrapper.eq("data_status", 2);
        wrapper.eq("collection_time", towerDataAlarmSearchVO.getCollectionTime());
        long alarmCount = towerDataAlarmMapper.selectCount(wrapper);
        alarmMap.put("alarmCount",alarmCount);
        return ApiResponse.success(alarmMap);
    }
}
